﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SIMCFachadaNegocio;
using SIMCObjetoNegocio;

namespace SIMCPresenter
{
    public interface IResumenPortafolioView : IViewBase
    {
        event EventHandler<SearchEventArgs<PortafolioSearchCriteria>> MostrarBalance;             
        TipoPortafolioCollection ListaTipoPortafolio { set; }
    }

    public class ResumenPortafolioPresenter : PresenterBase
    {
        private  IResumenPortafolioView mView;
        private FachadaPortafolio m_FachadaPortafolio;

        public ResumenPortafolioPresenter(IResumenPortafolioView view)
            : base(view)
        {
            this.mView = view;
            m_FachadaPortafolio = new FachadaPortafolio();
            this.Initialize();
        }

        private void Initialize()
        {
            this.mView.MostrarBalance += new EventHandler<SearchEventArgs<PortafolioSearchCriteria>>(mView_BuscarResumen);                    
        }

        private void mView_BuscarResumen(object sender, SearchEventArgs<PortafolioSearchCriteria> e)
        {
            try
            { 
                TipoPortafolioCollection Portafolios = m_FachadaPortafolio.BuscarTiposPortafolioCollection(e.Element, e.Element.Start, e.Element.Max);             
                mView.ListaTipoPortafolio = Portafolios;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                mView.MostrarMensaje(ex.Message, false);
            }
        }
               
    }
}
